Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports System.Data

Namespace DataAccess
    Public Class PointsData
        Public Shared Sub Claim(ByVal _Points As ModelLayer.IPoints)
            Using oDm As New DataManager()
                oDm.CommandType = CommandType.StoredProcedure
                oDm.Add("@Username ", SqlDbType.NVarChar, 50, _Points.Username)
                oDm.ExecuteNonQuery("ClaimPrizes")
            End Using
        End Sub

        Public Shared Sub Save(ByVal _Points As ModelLayer.IPoints)
            Using oDm As New DataManager()
                oDm.CommandType = CommandType.StoredProcedure
                If (_Points.Username.Length > 0) Then
                    oDm.Add("@Username ", SqlDbType.NVarChar, 50, _Points.Username)
                End If
                oDm.Add("@Activity ", SqlDbType.SmallInt, _Points.Activity)
                oDm.Add("@Comments ", SqlDbType.NVarChar, 500, _Points.Comments)
                oDm.Add("@IPAddress", SqlDbType.NChar, 15, _Points.IPAddress)
                oDm.ExecuteNonQuery("stp_AddPoints")
            End Using
        End Sub
        Public Shared Sub LoadPointsByUserName(ByVal _Points As ModelLayer.IPoints)
            Using oDm As New DataManager()
                oDm.CommandType = CommandType.StoredProcedure
                oDm.Add("@Username ", SqlDbType.NVarChar, 50, _Points.Username)
                Dim dt As DataTable
                dt = oDm.ExecuteDataTable("stp_GetPoints")
                If dt IsNot Nothing And dt.Rows.Count > 0 Then
                    If dt.Rows(0)("TotalPoints") IsNot DBNull.Value Then
                        _Points.TotalPoints = CInt(dt.Rows(0)("TotalPoints"))
                    End If
                End If
            End Using
        End Sub
    End Class
End Namespace